#include<iostream>
#include<vector>
#include<cstring>
#include<set>
using namespace std;
#define int long long
const int N = 2e5 + 10;

void solve()
{
    int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        // 计算原始逆序对数目
        int original_inv = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if (a[i] > a[j]) {
                    original_inv++;
                }
            }
        }

        int min_delta = 0;
        int best_l = 1, best_r = 1;

        for (int l = 0; l < n; ++l) {
            int greater = 0, less = 0;
            for (int r = l; r < n; ++r) {
                if (r > l) {
                    if (a[r] > a[l]) {
                        greater++;
                    } else if (a[r] < a[l]) {
                        less++;
                    }
                }
                int delta = greater - less;

                // 比较当前的delta是否更优
                if (r == l) {
                    // 此时delta为0，对应选择区间[l+1, r]为空，即原数组不变
                    if (0 < min_delta) {
                        min_delta = 0;
                        best_l = l + 1;
                        best_r = r + 1;
                    } else if (0 == min_delta) {
                        // 选择lex最小的？或者保持第一个
                        if (l + 1 < best_l || (l + 1 == best_l && r + 1 < best_r)) {
                            best_l = l + 1;
                            best_r = r + 1;
                        }
                    }
                } else {
                    if (delta < min_delta) {
                        min_delta = delta;
                        best_l = l + 1;
                        best_r = r + 1;
                    } else if (delta == min_delta) {
                        // 比较区间是否更优，选择lex更小的
                        if (l + 1 < best_l || (l + 1 == best_l && r + 1 < best_r)) {
                            best_l = l + 1;
                            best_r = r + 1;
                        }
                    }
                }
            }
        }

        cout << best_l << " " << best_r << "\n";
}
signed main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;

}